<script setup>
import { ref } from 'vue'
import { MYURL } from '@/utils/express/express.js'
import Vrouter from "@/router"
import { gethistory } from '@/api/video/video.js'
import time from '@/utils/time/time.js'
const router = Vrouter
const historyList = ref([])
gethistory().then((res) => {
    historyList.value = res.data.message
})
</script>


<template>
        <div class="get-back-main">
        <img class="back-image" src="@/assets/img/getback.png" @click="router.go(-1)">
        <div class="title">
            账号资料
        </div>
    </div>
    <div v-if="historyList.length === 0" class="empty">
        <IsEmpty>快去找一个视频看看吧</IsEmpty>
    </div>
    <div>
        <div class="video-info" v-for="video in historyList" @click="router.push(`videodetail?id=${video.id}`)"
            :key="video.id">
            <div class="video_profile">
                <img :src="MYURL + '/public/videoimages/' + video.image">
            </div>
            <div class="video_info_detail">
                <p class="video_title">{{ video.title }}</p>
                <p class="video_time">{{ time(parseInt(video.time))[0] }}</p>
                <div class="playbacks-main">
                    <img src="@/assets/img/playbacks.png">
                    <p>3.2万</p>
                </div>
            </div>
        </div>
    </div>
</template>

<style lang="less" scoped>
.get-back-main{
    position: sticky;
}
.empty {
    margin-top: 30px;
    display: flex;
    gap: 10px;
    flex-direction: column;
    align-items: center;

    div {
        padding: 10px;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #f6f5fa;
        border-radius: 50%;

        img {
            width: 25px;
            height: 25px;
        }
    }

    .send {
        color: #95999f;
    }

    .btn {
        border-radius: 30px;
        border: 1px solid var(--bilibili-pink);
        color: var(--bilibili-pink);
        padding: 10px 40px;
    }
}

.video-info {
    margin-top: 10px;
    padding: 0 20px;
    display: flex;
    gap: 10px;
    border-bottom: .7px solid rgba(0, 0, 0, 0.12);
    padding-bottom: 10px;

    .video_info_detail {
        display: flex;
        flex-direction: column;
    }

    .video_title {
        height: 40px;
        font-size: 15px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2; // 控制多行的行数
        -webkit-box-orient: vertical;
    }

    .video_time {
        color: #95999f;
        margin-left: 3px;
        font-size: 13px;
        margin: auto 0;
    }

    .playbacks-main {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 2px;

        img {
            width: 20px;
        }

        p {
            color: #95999f;
            font-size: 12px;
        }
    }

    .video_profile {
        height: 100%;
        display: flex;

        img {
            width: 150px;
            height: 80px;
            object-fit: contain;
            background-color: black;
            border-radius: 5px;
        }
    }
}
</style>
